package com.carbeauty.logic;

import java.io.File;
import java.util.HashMap;

public class ImageFingerLoader {
	private static ImageFingerLoader loder = new ImageFingerLoader();
	private HashMap<String,ImageCompareResult> imagedata= new HashMap<String,ImageCompareResult>();
	private ImageFingerLoader(){}
	public static ImageFingerLoader getInstance(){
		return loder;
	}
	public void clear()
	{
		imagedata.clear();
	}
	public HashMap load(File[] files)
	{
		this.clear();
		if(files==null)
		{
			return imagedata ;
		}
		for(File file:files)
		{
			try{
				ImageCompareResult hashCode = SimilarImageSearch.produceFingerPrint(file);
				imagedata.put(file.getAbsolutePath(), hashCode);
			}catch(Exception ex){
				System.out.println(file+"获取hashcode的时候出错");
				ex.printStackTrace();
			}
		}
		return imagedata ;
	}
	 
	public HashMap add(File file)
	{
		ImageCompareResult hashCode = SimilarImageSearch.produceFingerPrint(file);
		imagedata.put(file.getAbsolutePath(), hashCode);
		return imagedata;
	}
	
	
	
	
}
